<?php require_once 'inc_security.php';
$db_config = new db_query('SELECT * FROM configuration WHERE con_type = "footer" LIMIT 1');
$configDetail = mysql_fetch_assoc($db_config->result);
$conBase->init_config($configDetail['con_type'],json_decode(base64_decode($configDetail['con_value']),1));
$myform = new generate_form();
$action = getValue('action','str','POST','');

if($action == 'execute'){
    $con_value = array();
    $con_value['position'] = getValue('position','str','POST','');
    $con_value['custom_menu']['label'] = getValue('custom_menu_label','str','POST','');
    $con_value['custom_menu']['link'] = getValue('custom_menu_link','str','POST','');
    $con_value['showmenu'] = getValue('showmenu','int','POST',0);
    $con_value['content'] = prepare_text_article(getValue('content','str','POST',''));
    
    $con_value = base64_encode(json_encode($con_value));
    $myform->add('con_value','con_value',0,1,'');
    $myform->addTable($bg_table);
    $bg_errorMsg .= $myform->checkdata();
    if($bg_errorMsg == ''){
        $db_update = new db_execute($myform->generate_update_SQL('con_id',$configDetail['con_id']));
        unset($db_update);
        redirect('footerconfig.php?success=1');
    }
}

?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="vi" lang="vi" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?=$load_header?>
</head>
<body>
<div class="module_header bold fix"><?=$module_name?></div>
<div id="wrapper">
    <?=($bg_errorMsg ? '<div class="alert">'.$bg_errorMsg.'</div>' : '')?>
    <?=($bg_success ? '<div class="alert alert-success">'.'Cập nhật thành công'.'</div>' : '')?>
    <?php $form = new form();?>
    <?=$form->textnote('Thông tin footer')?>
    <?=$form->form_open()?>
    <?=$conBase->Admin_form_config_footer()?>
    <?php $get_config_value = $conBase->con_value;?>
    <?=$form->tinyMCE('Nội dung','content','content',$get_config_value['content'])?>
    <?=$form->form_action(array('label'=>array('Cập nhật','Nhập lại'),'type'=>array('submit','reset')))?>
    <?=$form->form_close()?>
</div>
</body>
</html>